package com.haidechizi.leetcode;

public class _114_二叉树展开为链表 {

    public void flatten(TreeNode root) {

        while (root != null) {
            TreeNode oldRight = root.right;
            root.right = root.left;
            root.left = null;
            TreeNode current = root;
            while (current.right != null) {
                current = current.right;
            }
            current.right = oldRight;
            root = root.right;
        }

    }
}
